<template>
	<view class="afterSale">
				<view class="item_content">
					<image :src="goods.image||'/pagesB/static/微信图片_20201124091755.png'" mode=""></image>
					<view class="ItemContent">
						<view class="title">{{goods.name}}</view>
						<view class="parameter">
							<view class="parameter1">{{ goods.option_name }}</view>
						</view>
						<view class="price_ctrlbox">
							<view class="price">￥{{ goods.price }}</view>
							<view class="ctrlbox">x{{ goods.quantity }}</view>
						</view>
					</view>
				</view>
		<view class="order_title">
			<view class="title_left">售后类型</view>
			<view class="radio">
				<view class="change" @click="radiochange()">
					<view class="radio" :class="active?1:'radioActive'" ></view>
					我要退款
				</view>
				<view class="change" @click="radiochange()">
					<view class="radio" :class="active==false?1:'radioActive'" ></view>
					我要退货
				</view>
			</view>
		</view>
		<view class="order_title">
			<textarea v-model="reason" placeholder="请输入问题描述" />
		</view>
		<view class="order_title">
			<view class="title_left">退款金额</view>
			<view class="price">￥{{ goods.price*goods.quantity }}元</view>
		</view>
		<view class="voucher">
			<view class="voucher_title">
				上传凭证
			</view>
			<view class="voucher_content">
				<image v-for="i in img" :key="i" :src="'http://'+i" class="sctu"></image>
				<view class="jia" @click="shangchuan">
					+
				</view>
			</view>
		</view>
		<view class="button">
			<button type="warn" @click="addmanagement">保存</button>
		</view>
	</view>
</template>

<script>
	import {requestUrl,imageUrl} from '@/common/config.js'
	import md5 from '@/common/api/md5.js'
	export default {
		data() {
			return {
				img:[],
				reason:'',
				active:true,
				Url:'',
				goods:[]
			};
		},
		onShow() {
			this.goods = JSON.parse(uni.getStorageSync('goods'));
			console.log(this.goods)
			let time = Math.round(new Date().getTime() / 1000).toString()
			let _this = this
			let Time = ['time', time].join('=')
			let Access_token = ['access_token', this.access_token].join('=')
			let content = ['content=pinet.FeiMao.2017'].join()
			let arr = [content, Time].sort(function(a, b) {
				a - b
			})
			let newarr = md5(arr.join('&'))
			uni.request({
				url: requestUrl+'/app/upload/getUploadConfig',
				method: "GET",
				data: {
					time: time,
					sign: newarr,
				},
				success: function(res) {
					console.log(res)
					_this.Url=res.data.content
				}
			});
		},
		methods:{
			radiochange(){
				this.active=!this.active
			},
			addmanagement(){
				this.goods.reason=this.reason
				this.goods.money=this.goods.price*this.goods.quantity
				this.goods.img=this.img
				uni.setStorage({
					key: 'goods',
					data: JSON.stringify(this.goods),
					success: function () {
					}
				});
				if(this.active){
				uni.navigateTo({
					url:'/pagesB/mine/mine/orderdetails/refound1'
				})					
				}else{
					uni.navigateTo({
						url:'/pagesB/mine/mine/orderdetails/afterSale1'
					})
				}
			},
			shangchuan(){
				let _this=this
				uni.chooseImage({
					count: 9, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: (res1) => {
						this.$UploadImg(res1.tempFilePaths[0],_this.Url.token).then(res=>{
							_this.img.push(res.imageURL)
						})
					}
				});
			},
		}
	}
</script>

<style lang="less">
	.afterSale{
		height: 100%;
		background: #F3F4F5;
		padding-top: 20rpx;
			.item_content {
				display: flex;
				padding: 20rpx;
				border-bottom: 1px solid #eeeeee;
				background-color: #fff;
				margin-bottom: 10rpx;
				image {
					height: 180rpx;
					width: 180rpx;
					margin-right: 16rpx;
				}
				.ItemContent {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.title {
						height: 72rpx;
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #111111;
					}
					.parameter {
						height: 34rpx;
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #9da5a8;
					}
					.price_ctrlbox {
						display: flex;
						justify-content: space-between;
					}
					.price {
						font-size: 28rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #111111;
					}
					.ctrlbox {
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #9da5a8;
					}
				}
			}
			.order_price1 {
				padding: 0 24rpx 24rpx 24rpx;
			}
			.order_price {
				margin-top: 24rpx;
				height: 100%;
				display: flex;
				justify-content: space-between;
				.price_left {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
				}
				.price_right {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
				}
				.price_right1 {
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #db1b22;
				}
			}
			.order_title {
				display: flex;
				padding: 30rpx;
				border-bottom: 1px solid #eeeeee;
				background-size: 28rpx 28rpx;
				background-color: #fff;
				.price{
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #DB1B22;
				}
				.radio{
					flex: 1;
					display: flex;
					.change{
						display: flex;
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #111111;
						.radio {
							width: 32rpx;
							height: 32rpx;
							background: url(/pagesB/static/selected%20active.png) 0px 0px;
							background-size: 32rpx 32rpx;
							margin: 0 10rpx;
							align-items: center;
						}
						.radioActive {
							background: url(/pagesB/static/selected／on.png) 0px 0px;
							background-size: 32rpx 32rpx;
						}
					}
				}
				.title_left {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
					margin-right: 30rpx;
				}
				textarea{
					width: 100%;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #9DA5A8;
				}
			}
			.voucher{
				padding: 30rpx;
				background-color: #fff;
				border-bottom: 1px solid #eeeeee;
				.voucher_title{
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
				}
				.voucher_content{
					display: flex;
					margin: auto;
					margin-top: 20px;
				}
				.sctu{
					width:80px;
					height:80px;
					margin-right: 15px;
				}
				.jia{
					width:80px;
					height:80px;
					background-color:#C8C7CC;
					color:#808080;
					text-align: center;
					line-height: 80px;
					font-size: 30px;
					font-weight: 700;
				}
			}
			.button {
					width: 90%;
					margin: 0 auto;
					padding: 40rpx 0;
					button{
						border-radius: 20px;
						line-height: 80rpx;
					}
				}
	}
</style>
